package com.hqyj.service.service;


import com.hqyj.dao.dao.TableDao;
import com.hqyj.pojo.MakeApply;
import com.hqyj.pojo.customerInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InsertDataImpl implements InsertData{
    @Autowired(required = false)
    TableDao tableDao;

    //用户增加数据库


    @Override
    public int addApply(MakeApply makeApply) {
        int flag = tableDao.insertApply(makeApply);
        if (flag>0){
            return 1;
        }
        return 0;
    }

    //后台用户卡片数据回显
    @Override
    public List<MakeApply> findFromApplyTable() {
        return tableDao.findFromApplyTable();
    }

    //点开处理，弹出层数据回显
    @Override
    public List<MakeApply> findByName(String userName) {
        return tableDao.findByName(userName);
    }


    //点开处理，弹出层数据回显,根据ID
    @Override
    public List<MakeApply> findById(String Id) {
        return tableDao.findById(Id);
    }

    //后台管理者提交数据，附加新的数据
    @Override
    public String updateApply(String customerId, String userName,String dealCalender, String predictCost, String serviceTime, String Dealed) {
        int flag =  tableDao.updateApply(customerId, userName, dealCalender, predictCost, serviceTime, Dealed);
        if (flag > 0){
            return "成功";
        }
        return "失败";
    }

    //顾客看到服务记录
    @Override
    public List<MakeApply> findByNameList(String userName) {
        return tableDao.findByNameList(userName);
    }

    //服务记录
    @Override
    public List<MakeApply> findSerList() {
        return tableDao.findSerList();
    }

    //修改remark
    @Override
    public String updateRemark(String remark, String Id) {
        int flag = tableDao.updateRemark(remark, Id);
        if (flag > 0){
            return "修改成功";
        }
        return "修改失败";
    }

    //获取用户的地址，邮箱
    @Override
    public List<customerInfo> askAddByName(String customerName) {
        return tableDao.askAddByName(customerName);
    }

}
